<template>
  <div class="head-search">
    <!-- 搜索 -->
    <el-select v-model="query.type" clearable placeholder="查找类型" class="filter-item" style="width: 130px">
      <el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
    </el-select>
    <el-input v-model="query.value" clearable placeholder="输入关键字搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery" />

    <el-select v-model="query.flag" clearable placeholder="日志类型" class="filter-item" style="width: 130px">
      <el-option v-for="item in sucessType" :key="item.key" :label="item.display_name" :value="item.key" />
    </el-select>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
  </div>
</template>
<script>
export default {
  props: {
    query: {
      type: Object,
      required: true
    },
    dicts: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'username', display_name: '操作用户' },
        { key: 'module', display_name: '接口' },
        { key: 'params', display_name: '入参' },
        { key: 'remoteaddr', display_name: '访问ip' }
      ],
      sucessType: [
        { key: 0, display_name: '成功' },
        { key: 1, display_name: '失败' }
      ]
    }
  },
  methods: {
    add() {
      this.$refs.form.dialog = true
    },
    toQuery() {
      this.$parent.page = 1
      this.$parent.init()
    }
  }
}
</script>
